import req from '../common/network'

export default {
  // 所有地址
  async list (userId) {
    return await req({
      method: 'GET',
      url: `/users/${userId}/addresses`,
    })
  },
  // 新建地址
  async create (userId, data) {
    return await req({
      method: 'POST',
      url: `/users/${userId}/addresses`,
      data,
    })
  },
  // 编辑地址
  async update (userId, data) {
    return await req({
      method: 'PUT',
      url: `/users/${userId}/addresses/${data.id}`,
      data,
    })
  },
  // 删除地址
  async delete (userId, data) {
    return await req({
      method: 'DELETE',
      url: `/users/${userId}/addresses/${data.id}`,
    })
  },
}
